<?php

/**
 * Static content controller.
 *
 * This file will render views from views/pages/
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
App::uses('AppController', 'Controller');

/**
 * Static content controller
 *
 * Override this controller by placing a copy in controllers directory of an application
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
 */
class ConfigurationsController extends AppController {

    /**
     * Controller name
     *
     * @var string
     */
    public $name = 'Configurations';

    /**
     * Default helper
     *
     * @var array
     */
    public $helpers = array('Html', 'Session');

    /**
     * This controller does not use a model
     *
     * @var array
     */
    public $uses = array();

    /**
     * Displays a view
     *
     * @param mixed What page to display
     * @return void
     */
    public function edit() {
//		// Parse without sections
//		$ini_array = parse_ini_file("configuration_.ini");
//		//print_r($ini_array);
//
//
//		$homepage = file_get_contents("css/theme.css");
//		//echo $homepage;
//		//echo WWW_ROOT;
//
//		// Parse with sections
//		$ini_array = parse_ini_file("configuration_.ini", true);
//		//echo "<br><br><br><br><br><br><br><br><br>";
//		//debug($_SESSION);
//		//		echo "here";
//
//		//		    $res = array();
//		//    foreach($array as $key => $val)
//		//    {
//		//        if(is_array($val))
//		//        {
//		//            $res[] = "[$key]";
//		//            foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"');
//		//        }
//		//        else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"');
//		//    }
//		//    safefilerewrite($file, implode("\r\n", $res));
    }

    public function admin_theme() {
        if (!empty($this->data)) {
            $bodytag = str_replace("#####", $this->webroot, $this->data["Configuration"]["style"]);
            $this->Cookie->write('style', $bodytag, false);
            $_COOKIE["style"]=$bodytag;
            $this->redirect(array('action' => 'theme'));
        }
     }

}
